// 验证规则
$('#myPro').validate({
    rules: {
        email: {
            required: true,
            email: true
        },
        name: {
            required: true,
            maxlength: 5
        },
        tel: {
            required: true,
            tel: true
        }
    },
    messages: {
        email: {
            required: "不能为空"
        },
        name: {
            required: "不能为空"
        },
        tel: {
            required: "不能为空"
        }
    },
    errorPlacement: function (error, element) {
        $(element).siblings('.u-ts').html(error)
    },
    errorElement: 'span',
    submitHandler: function (form) {
        form.submit();
    }
});

jQuery.validator.addMethod('telNum', function (value, element) {
    var phoneNum = /^[1][34578][\d]{9}$/.test(value);
    return this.optional(element) || phoneNum
}, '请输入正确手机号');

$('#filePic').on('change', function () {
    var reader = new FileReader();
    var files = this.files[0];
    reader.readAsDataURL(files);
    reader.onload = function () {
        if ((files.type === 'image/png' || files.type === 'image/jpeg') && files.size < 1169328)
            $('.filePic-li>div').html('<img src="' + reader.result + '">')
    }
});